import {
	request,
	baseUrl
} from "../request.js"

/**
 * 1，通过账号搜索
 * @param {Object} msgType
 * @param {Object} page
 * @param {Object} size
 */
export function getMsgBySystem(page, size, msgType) {
	return request({
		url: baseUrl + '/systemMsg/getMsgBySystem',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			msgType,
			page,
			size
		}
	})
}

/**
 * 2，根据id删除
 * @param {Object} id
 */
export function deleteById(id) {
	return request({
		url: baseUrl + '/systemMsg/deleteById/' + id,
		method: 'DELETE'
	})
}

/**
 * 3，删除所有系统消息
 * @param {Object} userId
 */
export function cleanAll() {
	return request({
		url: baseUrl + '/systemMsg/cleanAll?userId=' + uni.getStorageSync('userId'),
		method: 'GET'
	})
}

/**
 * 4，添加好友
 * @param {Object} item
 */
export function addFriend(item) {
	//console.log(item)
	return request({
		url: baseUrl + '/systemMsg/addFriend',
		method: 'POST',
		data: {
			receiverId: item.receiverId,
			senderHead: item.senderHead,
			senderId: item.senderId,
			senderName: item.senderName,
			state: item.state,
			sysType: item.sysType,
			addId: item.addId,
			createTime: item.createTime,
			groupId: item.groupId,
			id: item.id,
			message: item.message
		}
	})

}


/**
 * 5，添加好友进入群聊
 * @param {Object} item
 */
export function addGroup(item) {
	return request({
		url: baseUrl + '/systemMsg/addGroup',
		method: 'POST',
		data: {
			addId: item.addId,
			createTime: item.createTime,
			groupId: item.groupId,
			id: item.id,
			message: item.message,
			receiverId: item.receiverId,
			senderHead: item.senderHead,
			senderId: item.senderId,
			senderName: item.senderName,
			state: item.state,
			sysType: item.sysType
		}
	})
}